<!-- 搜索条件 -->
<template>
  <div>
    <a-form :data="queryData" :definition="queryDefinition" :span="6" :query="query" :reset="reset">

      <template v-slot:loanRange>
        <div style="padding-top:4px">
          <el-input-number
            size="mini"
            placeholder="最小"
            :controls="false"
            :style="　{float: 'left',width:'50%'}"
            v-model="queryData.startLoanRange"
          />
          <el-input-number
            size="mini"
            placeholder="最大"
            :controls="false"
            :style="　{float: 'right',width:'50%'}"
            v-model="queryData.endLoanRange"
          />
        </div>
      </template>

    </a-form>
  </div>
</template>

<script>
export default {
  name: "query",
  props: {
    // 搜索条件
    queryData: {
      type: Object,
      required: true
    },
    type: {
      type: Number,
      required: true
    }
  },
  data() {
    return {
      // 搜索表单定义
      queryDefinition: [
        {
          prop: 'name',
          label: '姓名'
        },
        {
          prop: 'phoneNumber',
          label: '手机号',
          itemType: 'number'
        },
        {
          prop: 'level',
          label: '客户星级',
          type: 'select',
          dict: 'customer_level'
        },
        {
          prop: 'status',
          label: '状态',
          type: 'select',
          dict: 'customer_status'
        },
        {
          prop: 'dateRange',
          type: 'dateRange',
          label: '创建时间'
        },
        {
          prop: 'hasCar',
          label: '车辆',
          type: 'select',
          option: [
            {
              key: 1,
              label: '有车辆'
            },
            {
              key: 0,
              label: '无车辆'
            }
          ]
        },
        {
          prop: 'hasInsurance',
          label: '保单',
          type: 'select',
          option: [
            {key: 1, label: '有保单'},
            {key: 0, label: '无保单'}
          ]
        },
        {
          prop: 'hasHouse',
          label: '房产',
          type: 'select',
          option: [
            {key: 1, label: '有房产'},
            {key: 0, label: '无房产'}
          ]
        },
        {
          prop: 'loanRange',
          label: '贷款区间(万)',
          type: 'slot'
        },
        {
          prop: 'remark',
          label: '备注'
        },
        {
          prop: 'userId',
          label: '所属人',
          type: 'select',
          option: [],
          if: ()=> this.type ==1
        }
      ]
    }
  },
  methods: {
    query() {
      this.queryData.pageNum = 1
      this.$emit('getList')
    },
    reset() {
      this.$emit('update:queryData', {pageNum: 1, pageSize: 10})
      this.$emit('getList')
    }
  }
}
</script>

<style scoped>

</style>
